package cn.e3mall;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.context.annotation.Import;
import org.springframework.jmx.support.RegistrationPolicy;

import com.github.pagehelper.PageHelper;
import com.github.tobato.fastdfs.FdfsClientConfig;

import cn.e3.common.jedis.JedisClientPool;
import redis.clients.jedis.JedisPool;

@SpringBootApplication
public class ManagerSerApp {
	
	@Value("${spring.redis.host}")
	String redisHost;
	
	@Value("${spring.redis.port}")
	int redisPort;
	
	@Bean("jedisClientPool")
	public JedisClientPool getJedisClientPool(){
		return new JedisClientPool();
	}
	
	@Bean("jedisPool")
	public JedisPool getJedisPool(){
		return new JedisPool(redisHost,redisPort);
	}
	
	public static void main(String[] args) {
		SpringApplication.run(ManagerSerApp.class, args);
	}
	
	@Bean
	public PageHelper pageHelper() {
		PageHelper pageHelper = new PageHelper();
		return pageHelper;
	}
	
	/**
	 * 导入FastDFS-Client组件
	 * 
	 * @author tobato
	 *
	 */
	@Configuration
	@Import(FdfsClientConfig.class)
	// 解决jmx重复注册bean的问题
	@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
	public class ComponetImport {
	    // 导入依赖组件
	}
}
